Skip to content

fix(manager): allow to set unlimited per page limit in deployment#2241

Merged
jdobes merged 1 commit intoRedHatInsights:masterfrom
jdobes:page_limit_disable
Feb 26, 2026
Merged

fix(manager): allow to set unlimited per page limit in deployment#2241
jdobes merged 1 commit intoRedHatInsights:masterfrom
jdobes:page_limit_disable

Conversation

@jdobes
Copy link
Member

@jdobes jdobes commented Feb 26, 2026

RHINENG-24348

Secure Coding Practices Checklist GitHub Link

Secure Coding Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

Summary by Sourcery

Bug Fixes:

  • Fix enforcement of page size limits so that a non-positive configured maximum is treated as unlimited rather than blocking large requests.

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 26, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts list argument parsing to allow an unlimited per-page limit when configured, by only enforcing the maximum page size check if a positive maximum is set.

Flow diagram for list argument limit validation logic

flowchart TD
    A[Start _parse_list_arguments] --> B[Read limit from kwargs]
    B --> C[Read CFG.maximum_page_size]
    C --> D[Read referer from context.request.headers]
    D --> E{Is CFG.maximum_page_size > 0?}

    E -- No --> H[Skip max page size validation]
    H --> I[Return parsed arguments]

    E -- Yes --> F{Is limit > CFG.maximum_page_size?}
    F -- No --> I

    F -- Yes --> G{Does UI_REFERER match referer?}
    G -- Yes --> I
    G -- No --> J[Raise InvalidArgumentException]
Loading

File-Level Changes

Change Details Files
Conditionally enforce maximum page size only when a positive maximum is configured, allowing unlimited page size when the configured maximum is non-positive.
  • Update the page limit validation condition to first check that the configured maximum page size is greater than zero before comparing it against the requested limit
  • Preserve the referer-based exception that bypasses the limit for UI-originated requests
  • Keep the existing InvalidArgumentException message and behavior when the limit exceeds a positive configured maximum
manager/base.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions
Copy link
Contributor

github-actions bot commented Feb 26, 2026

SC Environment Impact Assessment

Overall Impact: 🟠 HIGH

View full report

Summary

  • Total Issues: 1
  • 🟠 High: 1

Detailed Findings

🟠 HIGH Impact

ClowdApp configuration change

  • File: deploy/clowdapp.yaml
  • Category: clowdapp_config
  • Recommendation: Verify all resource limits, environment variables, and dependencies are compatible with SC Environment. Check for any public cloud-specific features.

Required Actions

  • Review all findings above
  • Verify SC Environment compatibility for all detected changes
  • Update deployment documentation if needed
  • Coordinate with ROSA Core team or deployment timeline

This assessment was automatically generated. Please review carefully and consult with the ROSA Core team for critical/high impact changes.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Consider explicitly documenting or validating that CFG.maximum_page_size must be non-negative, since the new condition treats values <= 0 as disabling the limit and a negative value could unintentionally bypass the check.
  • It might be clearer to extract the CFG.maximum_page_size > 0 logic into a small helper (e.g., has_page_limit_enabled()) so the intent of allowing an unlimited page size when set to 0 is more obvious at the call site.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider explicitly documenting or validating that `CFG.maximum_page_size` must be non-negative, since the new condition treats values <= 0 as disabling the limit and a negative value could unintentionally bypass the check.
- It might be clearer to extract the `CFG.maximum_page_size > 0` logic into a small helper (e.g., `has_page_limit_enabled()`) so the intent of allowing an unlimited page size when set to 0 is more obvious at the call site.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@jdobes jdobes force-pushed the page_limit_disable branch from df16edd to 7fd548a Compare February 26, 2026 15:35
@vkrizan vkrizan self-requested a review February 26, 2026 15:39
- name: UNLEASH_BOOTSTRAP_FILE
value: ''
- name: MAXIMUM_PAGE_SIZE
description: Maximum number of items in a response, if set to 0 it's not limited
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we set the code-default to the 0 so the on prem deployments wouldn't require additional configuration? Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.maximum_page_size = int(os.getenv("MAXIMUM_PAGE_SIZE", "0"))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@jdobes jdobes force-pushed the page_limit_disable branch from 7fd548a to 08e1572 Compare February 26, 2026 16:52
Copy link
Collaborator

@vkrizan vkrizan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@jdobes jdobes merged commit e456170 into RedHatInsights:master Feb 26, 2026
9 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants